<template>
  <div id="nav">
    <div v-for="menu in menus" :class="$route.path==menu.path?'active':''" @click="toggle(menu.path)" :key="menu.path">
      <i :class="menu.icon"></i>
      <p>{{menu.name}}</p>
    </div>
    
  </div>
</template>

<script>
export default {

  data() {
    return {
     menus: [
        { name:'外卖', icon: 'iconfont icon-u',path: '/home' },
        { name:'搜索', icon: 'iconfont icon-sousuo',path: '/search' },
        { name:'订单', icon: 'iconfont icon-order',path: '/order' },
        { name:'我的', icon: 'iconfont icon-person',path: '/profile' }
      ]
    }
  },
  methods: {
    toggle(path) {
      this.$router.replace(path);
    }
  },
}
</script>

<style lang="scss" scoped>
#nav {
  position: fixed;
  display: flex;
  align-items: stretch;
  //flex: 1;
  justify-content: stretch;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 64px;
  background-color: $nav-bg-color;
  border-top: solid 1px #e0e0e0;
  div {
    width: 25%;
    height: 100%;
    padding: 10px;
    text-align: center;
    &.active {
       color: $nav-text-color-active;
       background-color: $nav-bg-color-active;
    }
    i {
      font-size: 26px;
      width: 26px;
      height: 28px;
    }
    p {
      font-size: 16px;
    }
  }
}
</style>